- if page.new?
  - title params[:path].blank? ? :new_page.t : "#{:new_page.t}: #{params[:path]}"
- else
  - title params[:pos] ? :edit_page_section.t(page: page.title) : :edit_page.t(page: page.title)
h1= title
= flash_messages
= page.editable? ? tabs(:edit, :upload, :attributes) :  tabs(:upload, :attributes)
form action=build_path(page.new? ? nil : page.path) method='post'
  - if page.editable?
    #tab-edit.tab
      h2= :edit.t
      ruby:
        content =
          if params[:content]
            params[:content]
          else
            params[:pos] ? page.content[params[:pos].to_i, params[:len].to_i].to_s : page.content
          end
      - if page.new?
        label for='edit-path' = :path.t
        &text#edit-path name='path' value=params[:path]
        br
        hr
      - else
        &hidden name='version' value=page.version
        - if params[:pos]
          &hidden name='pos' value=params[:pos]
          &hidden name='len' value=content.size
      textarea#edit-content.observe name='content' cols='100' rows='20' = content
      br
      label for='edit-comment' = :comment.t
      &text#edit-comment name='comment' value=params[:comment] size='50'
      = wrap_block :edit_buttons do
        button&submit name='action' value='edit' = :save.t
        button&submit name='action' value='edit-close' = :save_and_close.t
        button&reset = :reset.t
        br
form action=build_path(page.new? ? nil : page.path) method='post' enctype='multipart/form-data'
  #tab-upload.tab
    h2= :upload_file.t
    - if page.new?
      label for='upload-path' = :path.t
      &text#upload-path name='path' value=params[:path]
      br
      hr
    - else
      &hidden name='version' value=page.version
    label for='upload-file' = :file.t
    &file#upload-file.observe name='file'
    br
    = wrap_block :upload_buttons do
      button&submit name='action' value='upload' = :save.t
      button&submit name='action' value='upload-close' = :save_and_close.t
      button&reset = :reset.t
      br
form action=build_path(page.new? ? nil : page.path) method='post'
  #tab-attributes.tab.fieldset
    h2= :attributes.t
    - if page.new?
      label for='attributes-path' = :path.t
      &text#attributes-path name='path' value=params[:path]
      br
      hr
    - else
      &hidden name='version' value=page.version
    = page.attribute_editor
    = wrap_block :attributes_buttons do
      .indent
        button&submit name='action' value='attributes' = :save.t
        button&submit name='action' value='attributes-close' = :save_and_close.t
        button&reset = :reset.t
      br
